import * as _ from "@/utils/MyFun";
import * as TYPE from "../action-type";

let initialValue = {
  accessRoutes: [], //可访问的路由
  completeRouting: [], // 完整的路由
};

const PermissionReducer = (state = initialValue, action) => {
  state = _.clone(state);
  switch (action.type) {
    case TYPE.PERMISSION_GENERATEROUTESBACK:
      state.accessRoutes = action.accessRoutes;
      break;
    case TYPE.PERMISSION_RESETPERMISSION:
      state.accessRoutes = [];
      break;
    case TYPE.PERMISSION_COMPLETEROUTING:
      state.completeRouting = action.routes;
      break;
    default:
      state = { ...state };
  }
  return state;
};

export default PermissionReducer;
